﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NLBS.Control;
using NLBS;
using NLBS.Web;
using NLBS.Data;
using NLBS.Data.Business;

namespace NLBS
{
    public partial class comment : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DeleteComment();
            BindData();
            this.Title = "评论列表";
        }

        void BindData()
        {
            if (Request.QueryString["act"] != null)
            {
                string act = Request.QueryString["act"].ToString();
                if (act == "edit")
                {
                    commentForm msg = (commentForm)LoadControl("Control/commentForm.ascx");
                    msg.Action = MessageType.EditComment;
                    comment1.Visible = false;
                    this.Master.FindControl("mainWrapper").Visible = true;
                    this.Master.FindControl("mainWrapper").Controls.Clear();
                    this.Master.FindControl("mainWrapper").Controls.Add(msg);
                }
                else
                {
                    this.Master.FindControl("mainWrapper").Visible = true;
                    this.Master.FindControl("mainWrapper").Controls.Clear();
                    MessageHelp.ShowCommentAction(this,comment1);
                }
            }
        }

        private void DeleteComment()
        {
            if (Request.QueryString["act"] == "delete")
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);
                CommentData.DeleteCommentByID(id);
            }
        }
    }
}
